package com.sxau.plantingstructuretuning.controller;

import com.sxau.plantingstructuretuning.model.dto.PlantingStructureTuningRequestDTO;
import com.sxau.plantingstructuretuning.model.utils.Result;
import com.sxau.plantingstructuretuning.service.PlantingStructureTuningService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@CrossOrigin(origins = "*", allowedHeaders = "*")
@RequiredArgsConstructor

public class PlantingStructureTuningController {

    private final PlantingStructureTuningService plantingStructureTuningService;

    @PostMapping("/tuning")
    public Result getPlantingStructure(@RequestBody PlantingStructureTuningRequestDTO plantingStructureTuningRequestDTO) {
        Result process = plantingStructureTuningService.process(plantingStructureTuningRequestDTO.getYear(), plantingStructureTuningRequestDTO.getCounty());
        return Result.success(process);
    }
}
